<%@page import="com.funtl.framework.web.util.BaseInfo"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<title><%=BaseInfo.PROJECT_NAME%> - 错误日志</title>
<jsp:include page="/head.jsp" />
<script type="text/javascript">
	function subError(val, row) {
		if (val.length > 50) {
			return val.substring(0, 50) + "...";
		} else {
			return val;
		}
	}
	
	function detail() {
		var row = $("#dg_list").datagrid('getSelected');
    	if (row == null) {
    		dialog.info("请选择一条记录");
    	} else {
    		$("#win").html("");
    		windows.open("win", "错误日志");
    		$("#win").html(row.directions);
    	}
	}
	
	function del() {
		dialog.confirm("确定要删除记录吗？", function() {
			ajax.post("system/log/error/ajax/delete", null, function(data) {
				if (data.message == null || data.message.length == 0) {
					$("#dg_list").datagrid("reload");
					dialog.info("删除成功");
				} else {
					dialog.info(data.message);
				}
			});
		});
	}
</script>
</head>

<body>
	<table id="dg_list" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,pagination:true,pageSize:10,url:'system/log/error/ajax/query',toolbar:'#dg_list_toolbar'">
  		<thead>
  			<tr>
  				<th data-options="field:'message'">错误类型</th>
  				<th data-options="field:'directions', formatter:subError">详细日志</th>
  				<th data-options="field:'ip'">IP地址</th>
  				<th data-options="field:'createName'">创建人</th>
  				<th data-options="field:'createDate', formatter:formatter.formatDateTime">创建日期</th>
  			</tr>
  		</thead>
  	</table>
  	<div id="dg_list_toolbar" style="padding:5px;height:auto">
   		<div style="margin-bottom:5px">
   			<a class="easyui-linkbutton" data-options="plain:true" onclick="detail();">查看详情</a>
			<a class="easyui-linkbutton" data-options="plain:true" onclick="del();">清空日志</a>
		</div>
   	</div>
   	
   	<div id="win"></div>
</body>
</html>